﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;
using Negocio;
using Mundialeitor.App_Util;

namespace Mundialeitor
{
    public partial class Login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                Session.Clear();
            }
            catch (Exception ex)
            {
                
            }
        }

        protected void controlLogin_Authenticate(object sender, AuthenticateEventArgs e)
        {
            try
            {
                var regla = new UsuarioRules();

                string user = controlLogin.UserName.Trim();
                string pass = controlLogin.Password.Trim();

                var usuario = regla.ValidarUsuario(user, pass);

                if (usuario != null)
                {
                    Session["usuario"] = usuario;
                    Response.Redirect(PagesConstants.Inicio);   
                }
            }
            catch (Exception ex)
            {
                
            }
        }
    }
}
